<template>
    <div class="header-content">
        <div class="l-content">
            <el-button icon="el-icon-menu" style="margin-right: 20px;" @click="handMenu" size="mini"></el-button>
            <!-- 面包屑 -->
            <el-breadcrumb separator=">">
                <el-breadcrumb-item v-for="(item, index) in tags" :key="index" :to="{ path: item.path }">
                    {{ item.label }}
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown @command="handkeClick">
                <span class="el-dropdown-link">
                    <el-avatar> <img src="@/assets/images/user.png" alt=""> </el-avatar>
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item command="logout">退出登录</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>

<script>
import Cookie from 'js-cookie';
import { mapState } from 'vuex';

export default {
    name: 'CommonHeader',
    methods: {
        /* 点击折叠菜单按钮 */
        handMenu() {
            this.$store.commit('collapseMenu')
        },
        handkeClick(command) {
            if (command == 'logout') {
                Cookie.remove('token')
                Cookie.remove('menu')
                this.$router.push('/login')
                this.$store.commit('handtableList')
            }
        }
    },
    computed: {
        ...mapState({
            tags: state => state.tab.tabList
        })
    },
}
</script>

<style lang="less" scoped>
.header-content {
    background-color: #333;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;

    .text {
        color: #fff;
        font-size: 14px;
        margin-left: 10px;
    }

    .l-content {
        display: flex;
        align-items: center;

        /deep/.el-breadcrumb__item {
            .el-breadcrumb__inner {
                font-weight: normal;

                &.is-link {
                    color: #666;
                }
            }

            &:last-child {
                .el-breadcrumb__inner {
                    color: #fff;
                }
            }
        }
    }
}
</style>